package com.acme.bankapp.domain.bank;

public class CheckingAccount extends AbstractAccount {
	protected double overdraft;

	public CheckingAccount(double balance, double overdraft) {
		super(balance);
		this.overdraft = overdraft;
	}

	public void withdraw(double amount) {
		if (amount <= 0) {
			// MYTODO: throw exception
		} else if (amount > this.balance + this.overdraft) {
			// MYTODO: throw exception
		} else {
			// NB: in class we decided that it's not correct to change overdraft
			// value. Instead of that, we allow negative balance values.
			balance -= amount;
		}

		assert (balance > -overdraft);
	}

	public double getMaximumAmountToWithdraw() {
		return balance + overdraft;
	}

}
